import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { BillTagQuery, BillTagPageResult, BillTagForm } from "./types";

/**
 * 获取账单Tag分页数据
 *
 * @param queryParams
 */
export function getBillTagPage(
  queryParams?: BillTagQuery
): AxiosPromise<BillTagPageResult> {
  return request({
    url: "/api/v1/billTags/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取账单Tag下拉数据
 *
 * @param queryParams
 */
export function getBillTagOptions(
  queryParams?: BillTagQuery
): AxiosPromise<OptionType[]> {
  return request({
    url: "/api/v1/billTags/options",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取账单Tag详情
 *
 * @param id
 */
export function getBillTagForm(id: number): AxiosPromise<BillTagForm> {
  return request({
    url: "/api/v1/billTags/" + id + "/form",
    method: "get",
  });
}

/**
 * 添加账单Tag
 *
 * @param data
 */
export function addBillTag(data: BillTagForm) {
  return request({
    url: "/api/v1/billTags",
    method: "post",
    data: data,
  });
}

/**
 * 更新账单Tag
 *
 * @param id
 * @param data
 */
export function updateBillTag(id: number, data: BillTagForm) {
  return request({
    url: "/api/v1/billTags/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 批量删除账单Tag，多个以英文逗号(,)分割
 *
 * @param ids
 */
export function deleteBillTags(ids: string) {
  return request({
    url: "/api/v1/billTags/" + ids,
    method: "delete",
  });
}
